home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_008 / src / hack.track.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  619b  |  38 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
  2.  
  3. #include "hack.h"
  4. #ifdef TRACK
  5. #define    UTSZ    50
  6.  
  7. coord utrack[UTSZ];
  8. int utcnt = 0;
  9. int utpnt = 0;
  10.  
  11. initrack(){
  12.     utcnt = utpnt = 0;
  13. }
  14.  
  15. /* add to track */
  16. settrack(){
  17.     if(utcnt < UTSZ) utcnt++;
  18.     if(utpnt == UTSZ) utpnt = 0;
  19.     utrack[utpnt].x = u.ux;
  20.     utrack[utpnt].y = u.uy;
  21.     utpnt++;
  22. }
  23.  
  24. coord *
  25. gettrack(x,y) register int x,y; {
  26. register int i,cnt;
  27. coord tc;
  28.     cnt = utcnt;
  29.     for(i = utpnt-1; cnt--; i--){
  30.         if(i == -1) i = UTSZ-1;
  31.         tc = utrack[i];
  32.         if((x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y) < 3)
  33.             return(&(utrack[i]));
  34.     }
  35.     return(0);
  36. }
  37. #endif TRACK
  38.